import { createApp, onMounted } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 统一不同浏览器标签默认样式
import 'normalize.css'
import '@/styles/font/iconfont.css'
import '@/styles/index.scss'
import 'element-plus/dist/index.css'
import * as ELIcons from '@element-plus/icons-vue'
import ui from './components/library'
import directives from './directives/index'

/* md编辑器 */
import VMdEditor from '@kangc/v-md-editor/lib/codemirror-editor'
import '@kangc/v-md-editor/lib/style/codemirror-editor.css'
import githubTheme from '@kangc/v-md-editor/lib/theme/github.js'
import '@kangc/v-md-editor/lib/theme/style/github.css'
// highlightjs
import hljs from 'highlight.js'

// codemirror 编辑器的相关资源
import Codemirror from 'codemirror'
// mode
import 'codemirror/mode/markdown/markdown'
import 'codemirror/mode/javascript/javascript'
import 'codemirror/mode/css/css'
import 'codemirror/mode/htmlmixed/htmlmixed'
import 'codemirror/mode/vue/vue'
// edit
import 'codemirror/addon/edit/closebrackets'
import 'codemirror/addon/edit/closetag'
import 'codemirror/addon/edit/matchbrackets'
// placeholder
import 'codemirror/addon/display/placeholder'
// active-line
import 'codemirror/addon/selection/active-line'
// scrollbar
import 'codemirror/addon/scroll/simplescrollbars'
import 'codemirror/addon/scroll/simplescrollbars.css'
// style
import 'codemirror/lib/codemirror.css'
/* 处理时间戳 */
import moment from 'moment'
// import 'moment/dist/locale/zh-cn'
moment.defineLocale('zh-cn', {
    relativeTime: {
        future: '%s内',
        past: '%s前',
        s: '5秒',
        m: '1 分钟',
        mm: '%d 分钟',
        h: '1 小时',
        hh: '%d 小时',
        d: '1 天',
        dd: '%d 天',
        M: '1 个月',
        MM: '%d 个月',
        y: '1 年',
        yy: '%d 年'
    }
})

VMdEditor.Codemirror = Codemirror
VMdEditor.use(githubTheme, {
    Hljs: hljs
})
const app = createApp(App)
for (const iconName in ELIcons) {
    app.component(iconName, ELIcons[iconName])
}

app.use(VMdEditor)
app.use(ui)
app.use(directives)
app.config.globalProperties.$moment = moment
app.use(store).use(router).mount('#app')